// 初始化轮播插件
var mySwiper = new Swiper ('.swiper', {
    autoplay:true, //自动切换
    loop: true, // 循环模式选项
    
    // 如果需要分页器
    pagination: {
      el: '.swiper-pagination',
      clickable :true,
    },
    // 如果需要前进后退按钮
    navigation: {
      nextEl: '.swiper-button-next',
      prevEl: '.swiper-button-prev',
    },
  }) 

//   API分类
  let li  = document.querySelectorAll('.api-list li') 
  li.forEach(function(v,i){
      v.addEventListener('mouseover',function(){
        v.style.background = 'rgba(47,126,233)'
        this.querySelector('img').src = `../imgs/api0${i+1}-c.svg`
        this.querySelector('p').style.color = '#fff'
      })

      v.addEventListener('mouseout',function(){
        v.style.background = '#fff'
        this.querySelector('img').src = `../imgs/api0${i+1}.svg`
        // console.log(this.querySelector('img'));
        this.querySelector('p').style.color = '#000'
      })
  })


  // 助力企业
  let businessImg = document.querySelectorAll('#businessLeft img')
  let businessP = document.querySelectorAll('.business-right div')
  let businessCount = document.querySelector('.business-count')
  console.log(businessCount);
  // console.log(businessP);
  // console.log(businessImg);
  let index = 0;
  let timeId =  setInterval(hrl,1500)

    businessCount.addEventListener('mouseover',function(){
      clearInterval(timeId)
    })

    businessCount.addEventListener('mouseout',function(){
       timeId =  setInterval(hrl,1500)
    })

    function hrl(){
       // console.log(index);
       businessImg[index].classList.remove('active')
       businessP[index].classList.remove('on')
       ++index
       if(index == businessImg.length){
         index = 0
       }
      businessImg[index].classList.add('active')
      businessP[index].classList.add('on')
    }
  // 回到顶部
  let retTop = document.querySelector('.retTop')
 window.addEventListener('scroll',function(){
  let retDis = document.documentElement.scrollTop
  console.log(retDis);
  if(retDis>590){
    retTop.style.display = 'block'
  }else{
    retTop.style.display = 'none'
  }
 })

 retTop.addEventListener('click',function(){
   window.scrollTo({
     top : 0,
     behavior : 'smooth'
   })
 })

 retTop.addEventListener('mouseover',function(){
   retTop.style.backgroundPositionY = '-98px'
 })

 retTop.addEventListener('mouseout',function(){
  retTop.style.backgroundPositionY = '-56px'
})
  
